﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Green.AgileMapper
{
    public class ObjectMapperManager
    {
        public static ObjectMapperManager _defaultInstance = null;

        public static ObjectMapperManager Default
        {
            get
            {
                if (_defaultInstance == null)
                {
                    lock (typeof(ObjectMapperManager))
                    {
                        if (_defaultInstance == null)
                        {
                            _defaultInstance = new ObjectMapperManager();
                        }
                    }
                }
                return _defaultInstance;
            }
        }

        public virtual IObjectMapper<TFrom, TTo> GetMapper<TFrom, TTo>()
        {
            return GetMapper<TFrom, TTo>(new AttributeMappingConfigurator());
        }

        public virtual IObjectMapper<TFrom, TTo> GetMapper<TFrom, TTo>(IMappingConfigurator configurator)
        {
            return new DefaultObjectMapper<TFrom, TTo>(configurator);
        }

        public virtual IObjectMapper GetMapper()
        {
            return GetMapper( new AttributeMappingConfigurator());
        }

        public virtual IObjectMapper GetMapper(IMappingConfigurator configurator)
        {
            return new DefaultObjectMapper(configurator);
        }
    }
}
